package com.example.demo2.common.config.web.exception;

import com.example.demo2.common.config.web.ErrorEnum;
import lombok.Data;

@Data
public class BusException extends RuntimeException {
    private int code = 500;
    private String msg;

    private ErrorEnum errorEnum;

    //对该异常类的构造方法进行补充，不写的化会默认只有一个无参构造
    public BusException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public BusException(ErrorEnum errorEnum) {
        super(errorEnum.getMsg());
        this.msg = errorEnum.getMsg();
        this.code = errorEnum.getCode();
        this.errorEnum = errorEnum;
    }
    public BusException(String msg, int code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public BusException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public BusException(String msg, int code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }
}
